/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.flowumi.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ideacentre
 */
@Entity
@Table(name = "roles")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Roles.findAll", query = "SELECT r FROM Roles r"),
    @NamedQuery(name = "Roles.findByIdRoll", query = "SELECT r FROM Roles r WHERE r.idRoll = :idRoll"),
    @NamedQuery(name = "Roles.findByNombre", query = "SELECT r FROM Roles r WHERE r.nombre = :nombre"),
    @NamedQuery(name = "Roles.findByDescripcion", query = "SELECT r FROM Roles r WHERE r.descripcion = :descripcion"),
    @NamedQuery(name = "Roles.findByValorExterno", query = "SELECT r FROM Roles r WHERE r.valorExterno = :valorExterno")})
public class Roles implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idRoll")
    private Integer idRoll;
    @Size(max = 45)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 45)
    @Column(name = "descripcion")
    private String descripcion;
    @Size(max = 45)
    @Column(name = "valorExterno")
    private String valorExterno;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idRoll")
    private Collection<Usuarios> usuariosCollection;

    public Roles() {
    }

    public Roles(Integer idRoll) {
        this.idRoll = idRoll;
    }

    public Integer getIdRoll() {
        return idRoll;
    }

    public void setIdRoll(Integer idRoll) {
        this.idRoll = idRoll;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getValorExterno() {
        return valorExterno;
    }

    public void setValorExterno(String valorExterno) {
        this.valorExterno = valorExterno;
    }

    @XmlTransient
    public Collection<Usuarios> getUsuariosCollection() {
        return usuariosCollection;
    }

    public void setUsuariosCollection(Collection<Usuarios> usuariosCollection) {
        this.usuariosCollection = usuariosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRoll != null ? idRoll.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Roles)) {
            return false;
        }
        Roles other = (Roles) object;
        if ((this.idRoll == null && other.idRoll != null) || (this.idRoll != null && !this.idRoll.equals(other.idRoll))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.flowumi.entity.Roles[ idRoll=" + idRoll + " ]";
    }
    
}
